import { FormInstance } from 'element-plus'

export const resetForm = (formEl: FormInstance | undefined) => {
    if (!formEl) return
    formEl.resetFields()
}

export const oauth2LoginUri = ()=>{
    const authIssue = import.meta.env.VITE_OAUTH2_ISSUE
    const clientId = import.meta.env.VITE_OAUTH2_CLIENT_ID
    const redirectUri = import.meta.env.VITE_OAUTH2_REDIRECT_URI
    const scopes = import.meta.env.VITE_OAUTH2_SCOPES
    return `${authIssue}/oauth2/authorize?client_id=${clientId}&response_type=code&scope=${scopes}&redirect_uri=${redirectUri}`
}

export const base64Client = () => {
    const clientId = import.meta.env.VITE_OAUTH2_CLIENT_ID
    const clientSecret = import.meta.env.VITE_OAUTH2_CLIENT_SECRET
    return 'Basic ' + window.btoa(clientId + ':' + clientSecret)
}